package cas.ihep.hmss;

import cas.ihep.hmss.proto.HmssProtos;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * Created by chocolate on 2017/12/3.
 */
public class ClientHandler extends ChannelInboundHandlerAdapter{

    HmssProtos.JobSubmitRequest job;
    ClientHandler(HmssProtos.JobSubmitRequest j){
        job = j;
    }

    public void channelActive(ChannelHandlerContext ctx){
        ctx.writeAndFlush(job);
    }
    public  void exceptionCaught(ChannelHandlerContext ctx,Throwable cause){
        cause.printStackTrace();
        ctx.close();
    }

    public void channelRead(ChannelHandlerContext ctx, Object msg){
        HmssProtos.JobSubmitResponse resp=(HmssProtos.JobSubmitResponse)msg;
        System.out.println(resp);
        ctx.close();
    }
}
